package com.gitee.hljdrl.ffkit.bean;

import android.app.Activity;
import android.graphics.Color;
import android.os.Bundle;

import androidx.annotation.ColorInt;
import androidx.fragment.app.Fragment;

import com.gitee.hljdrl.ffkit.listener.OnExecuteListener;

import java.util.ArrayList;
import java.util.List;

public class FFKitLink {


    /**
     * 模块名字
     */
    public String name = "";

    /**
     * 模块描述
     */
    public String desc = "";

    public @ColorInt int color = Color.WHITE;

    public @ColorInt int textColor = Color.BLACK;
    /**
     * Activity启动方式
     */
    public Class<? extends Activity> activityClass;

    public Class<? extends Fragment> fragmentClass;

    public List<Class<? extends Fragment>> fragmentClassList;

    public Bundle bundle;

    /**
     * 自定义启动方式
     */
    public OnExecuteListener onExecuteListener;

    public boolean hasToolBar = false;


    public static class Builder {
        /**
         * 模块名字
         */
        public String name = "";

        /**
         * 模块描述
         */
        public String desc = "";

        public @ColorInt int color = Color.WHITE;
        public @ColorInt int textColor = Color.BLACK;
        /**
         * Activity启动方式
         */
        public Class<? extends Activity> activityClass;

        public Class<? extends Fragment> fragmentClass;

        public List<Class<? extends Fragment>> fragmentClassList;

        public Bundle bundle;
        /**
         * 自定义启动方式
         */
        public OnExecuteListener onExecuteListener;

        public boolean hasToolBar = false;

        public Builder setName(String name) {
            this.name = name;
            return this;
        }

        public Builder setColor(@ColorInt int color){
            this.color = color;
            return this;
        }

        public Builder setTextColor(@ColorInt int color){
            this.textColor = color;
            return this;
        }

        public Builder setDesc(String desc) {
            this.desc = desc;
            return this;
        }

        public Builder setOnExecuteListener(OnExecuteListener onExecuteListener) {
            this.onExecuteListener = onExecuteListener;
            return this;
        }

        public Builder setActivityClass(Class<? extends Activity> activityClass) {
            this.activityClass = activityClass;
            return this;
        }

        public Builder setFragmentClass(Class<? extends Fragment> fragmentClass) {
            this.fragmentClass = fragmentClass;
            return this;
        }

        public Builder addFragmentClassList(List<Class<? extends Fragment>> list) {
            if (fragmentClass != null) {
                if (fragmentClassList == null) {
                    fragmentClassList = new ArrayList<>();
                }
                fragmentClassList.addAll(list);
            }
            return this;
        }

        public Builder addFragmentClass(Class<? extends Fragment>... fragmentClass) {
            if (fragmentClass != null) {
                if (fragmentClassList == null) {
                    fragmentClassList = new ArrayList<>();
                }
                for (Class<? extends Fragment> item : fragmentClass) {
                    fragmentClassList.add(item);
                }
            }
            return this;
        }

        public Builder setToolBar(boolean hasToolBar) {
            this.hasToolBar = hasToolBar;
            return this;
        }

        public FFKitLink build() {
            FFKitLink build = new FFKitLink();
            //-----------------------------------------
            build.hasToolBar = hasToolBar;
            build.onExecuteListener = onExecuteListener;
            build.activityClass = activityClass;
            build.fragmentClass = fragmentClass;
            build.fragmentClassList = fragmentClassList;
            build.name = name;
            build.desc = desc;
            build.bundle = bundle;
            build.color = color;
            build.textColor = textColor;
            //-----------------------------------------
            return build;
        }
    }

}
